var path = require('path');
var webpack = require('webpack');
var publicPath = path.resolve(__dirname, 'public');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
	entry :{
		index: [
	        'webpack/hot/dev-server',
	        'webpack-dev-server/client?http://localhost:3000',
	        path.resolve(__dirname, 'app/index.js')
	    ],
		vendor: ['react', 'react-dom', 'react-router']
	},
	module: {
		loaders: [
        {
          test: /\.js$/,
          loader: 'babel-loader',
          exclude: path.resolve(__dirname, 'node_modules')
        },
        {
          test: /\.css/,
          //loader: ExtractTextPlugin.extract("style-loader", "css-loader")
					//{ test: /\.css$/, loader: ExtractTextPlugin.extract('style', 'css') }
					//loader: ExtractTextPlugin.extract('style', 'css')
					loader: 'style-loader!css-loader'
        }
      ]
	},
	output: {
        path: publicPath,   //编译到当前目录
        filename: "[name].min.js", //编译后的文件名字
        chunkFilename: "[name].min.js"
  },
  plugins:[
      new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js?[hash]'),
      //new webpack.optimize.CommonsChunkPlugin({names: ['vendor', 'manifest'],}),
      new webpack.HotModuleReplacementPlugin(),
  		new webpack.NoErrorsPlugin(),

			// new webpack.optimize.DedupePlugin(),
      // new webpack.optimize.OccurenceOrderPlugin(),
      // new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
			new HtmlWebpackPlugin({
        title: 'app',
        template: './app/index.html',
      })
  ],
	devServer: {
	    contentBase: "./app/static",
	    port: 3000,

	    inline: true,
	    historyApiFallback: true,

	    colors: true,
	    stats: 'normal',
	}
}
